﻿@{
    Layout = "../Shared/_MobileLayout.cshtml";
}
@model List<RiderShop.Mobile.ServiceEntity.MyAccount.UserShipingAddressExtend>
@section header
{
    <style>
        .myAccountActive {
            color: #ff6c1f;
        }
        footer {
            display: none;
        }
        .select {
            margin: 5px 0 0;
        }
    </style>

}
@section title
{
    编辑收货地址
}
@section pagetitle
{
    编辑收货地址
}
<div class="userCenterHeader">
    <span class="iconWrapper">
        <img src="~/Themes/RongJi/Style/base/imgs/icon_zhi.png">
    </span>
    <h3>编辑收货地址</h3>
    <br class="clearfix">
</div>
<form action="~/MyAccount/ShippingAddressEdit?action=@Request.QueryString["action"]" method="POST">
    <div class="box">
        <input name="txtUserName" type="text" id="txtUserName" class="form-control" placeholder="请填写收货人姓名" value="@Model[0].ShipTo">
        <input name="txtCellPhone" type="tel" id="txtCellPhone" class="form-control bmargin" placeholder="请填写收货人手机号" value="@Model[0].CellPhone">
        <div class="adress-select">
            <input type="hidden" name="RegionId" id="RegionId" value="@Model[0].RegionId">
            <fieldset>
                <legend>收货地址</legend>
                <select id="region" name="region" class="select">
                    <option value="" selected="selected">省份</option>
                    @foreach (var item in @Model[0].RegionList)
                    {
                        <option value="@item.RegionId">@item.RegionName</option>
                    }
                </select>
                <div class="srr">
                    <select id="city" name="city" class="select">
                        <option value="0">城市</option>
                    </select>
                    <select id="county" name="county" class="select">
                        <option value="0">区县</option>
                    </select>
                </div>
                <textarea name="txtAddress" id="txtAddress" class="form-control bmargin" rows="3" placeholder="请填写收货人详细地址(街道、小区、门牌号)">@Model[0].Address</textarea>
            </fieldset>
        </div>

        <input type="text" id="txtPostcode" name="txtPostcode" class="form-control bmargin" placeholder="请填写邮编" value="@Model[0].Zipcode">
        <input id="submit" type="submit" class="btn btn-danger btn-block bmargin" data-role="button" value="保存收货地址" />
        <input name="hidShippingId" type="hidden" id="hidShippingId" value="@Model[0].ShippingId">
    </>
</form>

@section footer
{
    <script type="text/javascript" src="~/Utility/pages/regionselect.js"></script>
    <script type="text/javascript">
        $(function () {
            //让toolbar选中
            var $homeImg = $("#homeImg");
            var $categoryImg = $("#categoryImg");
            var $myaccountImg = $("#myaccountImg");
            var $searchImg = $("#searchImg");

            $homeImg.attr("src", "/Themes/RongJi/Style/base/imgs/f10.png");
            $categoryImg.attr("src", "/Themes/RongJi/Style/base/imgs/f2.png");
            $myaccountImg.attr("src", "/Themes/RongJi/Style/base/imgs/f3_c.png");
            $searchImg.attr("src", "/Themes/RongJi/Style/base/imgs/f4.png");

            //var regionSelector = new vShop_RegionSelector('vshopRegion', function (address, code) {
            //    $("#address-check-btn").html(address + "<span class='caret'></span>");
            //    $('#RegionId').val(code);
            //}, $('#regionText').val());
            //加载用户之前选的省，市，区
            loadRegion(@Model[0].RegionId);
            //submit
            $("#submit").click(function () {
                var $shipTo = $.trim($("#txtUserName").val());
                var $cellPhone = $.trim($("#txtCellPhone").val());
                var $regionId = $("#RegionId").val();
                var $address = $.trim($("#txtAddress").val());

                if ($shipTo == "") {
                    KevinShop.MessageBox.Alert('请输入收货人');
                    return false;
                }
                if ($cellPhone == "") {
                    KevinShop.MessageBox.Alert('请输入手机号码');
                    return false;
                }

                reg = /^(\+\d{2,3}\-)?\d{11}$/;
                if (!reg.test($cellPhone)) {
                    KevinShop.MessageBox.Alert('请输入正确的手机号码');
                    return false;
                }
                if ($regionId == "") {
                    KevinShop.MessageBox.Alert('请选择地区');
                    return false;
                }

                if ($address == "") {
                    KevinShop.MessageBox.Alert('请输入收货地址');
                    return false;
                }
            });

        });
    </script>
}